package jxtend.processor.eclipse.visitor.traverser;

import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;

import jxtend.processor.eclipse.utils.ASTNodeUtils;

@SuppressWarnings("restriction")
public class LocalDeclarationTraverser implements ASTNodeChildrenTraverser {

	@Override
	public boolean isApplicable(ASTNode node) {
		return (node instanceof LocalDeclaration);
	}

	@Override
	public void traverseChildren(ASTNode node, ASTVisitor visitor, BlockScope scope) {
		LocalDeclaration localDeclaration = (LocalDeclaration) node;

		if (!(node instanceof Argument)) {
			ASTNodeUtils.traverseNullableNode(localDeclaration.initialization, visitor, scope);
		}

		ASTNodeUtils.traverseNullableNode(localDeclaration.type, visitor, scope);

		ASTNodeUtils.traverseArray(localDeclaration.annotations, visitor, scope);
	}
}
